
%!TEX program = xelatex
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[10pt]{article} 

\input{wang_preamble.tex}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{titling}
\setlength{\droptitle}{-2cm}   % This is your set screw

%%文档的题目、作者与日期
\author{王立庆（2019级数学与应用数学1班）}
\title{统计软件测验1}
%\date{\vspace{-3ex}}
%\renewcommand{\today}{\number\year \,年 \number\month \,月 \number\day \,日}
\date{2021年5月6日}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\maketitle


\begin{enumerate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %知识点：数据类型1：
从班级 $46$ 位同学里选 $5$ 位同学，编程计算一共有多少种可能。

\begin{myenumerate}
\item  1370754. %正确
\item  164490480.
\item  1370854.
\item  164490580.
\end{myenumerate}

{\color{red}答案解析：(a). 
这是组合数 $\binom{46}{5}=1370754$. 可使用函数 \,{\color{blue}\verb+choose+} 计算。或直接使用阶乘计算。
{\color{blue}
\begin{verbatim}
> choose(46,5)
[1] 1370754
> 46*45*44*43*42/1/2/3/4/5
[1] 1370754
\end{verbatim}
}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %知识点：数据类型2：
设随机变量 $X$ 服从正态分布 $N(10,25)$, 求概率 $\mathbb{P}(X\ge 8)$. 保留到三位小数点。
\begin{myenumerate}
\item  0.532.
\item  0.655. %正确
\item  0.755.
\item  0.832.

\end{myenumerate}

{\color{red}答案解析：(b). 
直接使用函数 \,{\color{blue}\verb+pnorm+} 计算，或者先化为标准正态分布再使用函数 \,{\color{blue}\verb+pnorm+} 计算。
\begin{eqnarray}
\mathbb{P}(X\ge 8) = \mathbb{P}\left( \frac{X-10}{5} \ge \frac{8-10}{5} \right) = \mathbb{P}(Z\ge -0.4) = 1-\Phi(-0.4).
\end{eqnarray}

{\color{blue}
\begin{verbatim}
> 1-pnorm(8,mean=10,sd=5)
[1] 0.6554217
> 1-pnorm(-0.4)
[1] 0.6554217
\end{verbatim}
}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %知识点：数据类型3：
设随机变量 $X$ 服从自由度为 $3$ 的 $\chi^2$ 分布，求分位数 $x$ 使得  $\mathbb{P}(X\ge x)=0.01$. 保留到三位小数点。
\begin{myenumerate}
\item  0.115.
\item  0.215.
\item  11.345. %正确
\item  12.345.

\end{myenumerate}

{\color{red}答案解析：(c). 
自由度为 $3$ 的 $\chi^2$ 分布是3个相互独立的标准正态分布的随机变量的平方和，即
\begin{eqnarray}
X = Y_1^2 + Y_2^2 +Y_3^2,
\end{eqnarray}
其中 $Y_i \overset{\text{iid}}{\sim} N(0,1)$. 
{\color{blue}
\begin{verbatim}
> qchisq(0.01,df=3)
[1] 0.1148318
> qchisq(0.99,df=3)
[1] 11.34487
\end{verbatim}
}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %知识点：数据类型4：
设随机变量 $X$ 服从离散分布 $\mathbb{P}(X=1)=0.2$, $\mathbb{P}(X=2)=0.3$, $\mathbb{P}(X=3)=0.5$. 如何生成服从这个分布的随机数 $x_1,\cdots, x_9$?

\begin{myenumerate}
\item  \,{\color{blue}\verb+> sample(c('2','3','5'),9,prob=c(0.2,0.3,0.5),replace=F)+}
\item  \,{\color{blue}\verb+> sample(c('2',‘3','5'),9,prob=c(0.2,0.3,0.5),replace=T)+}
\item  \,{\color{blue}\verb+> sample(c('1','2','3'),9,prob=c(0.2,0.3,0.5),replace=F)+}
\item  \,{\color{blue}\verb+> sample(c('1','2','3'),9,prob=c(0.2,0.3,0.5),replace=T)+} %正确

\end{myenumerate}

{\color{red}答案解析：(d).
使用函数 \,{\color{blue}\verb+sample+} 生成随机数，指定相应的参数。
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %知识点：数据类型5：
设两位裁判给 $6$ 位运动员的打分如下。计算斯皮尔曼相关系数，
\begin{center}
\begin{tabular}{|c|cccccc|} \hline 
运动员 & A & B & C & D & E & F   \\ \hline 
裁判甲 & $4$ & $2$ & $6$ & $1$ & $3$ & $5$  \\ \hline
裁判乙 & $2$ & $5$ & $1$ & $3$ & $4$ & $6$  \\ \hline
\end{tabular}
\end{center}
提示：斯皮尔曼相关系数的计算公式为
\begin{eqnarray}
\rho = 1- \frac{6}{n(n^2-1)} \sum\limits_{i=1}^{n} d_i^2. 
\end{eqnarray}

\begin{myenumerate}
\item  $-0.257$. %正确
\item  $-0.357$.
\item  $-0.457$.
\item  $-0.557$.

\end{myenumerate}

{\color{red}答案解析：(a). 
代入两个名次，按公式计算。
{\color{blue}
\begin{verbatim}
> a<-c(4,2,6,1,3,5)
> b<-c(2,5,1,3,4,6)
> sp<-1-6*sum((a-b)^2)/6/35
> sp
[1] -0.2571429
\end{verbatim}
}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %知识点：数据类型6：
载入程序包 {\color{blue}\verb+ISwR+}, 载入数据框 {\color{blue}\verb+rmr+}. 
用体重作自变量 $x$, 代谢率作因变量 $y$, 拟合一条直线。下述说法中，不正确的是哪个？

\begin{myenumerate}
\item  样本回归方程为 $\hat{y} = 811.23 + 7.06x$.
\item  标准误为 $\hat{\sigma}=157.9$. 
\item  该线性模型非常显著。
\item  设置信度为 95\%, 体重 60 公斤的代谢率的预测值的预测区间为 $[811.2 1658.4]$. %不正确

\end{myenumerate}

{\color{red}答案解析：(d). 
预测区间为 $[911.2 1558.4]$.
{\color{blue}
\begin{verbatim}
> library(ISwR)
> attach(rmr)
> lm01<-lm(metabolic.rate~body.weight)
> summary(lm01)
> predict(lm01,int='p',newdata=data.frame(body.weight=60))
       fit      lwr      upr
1 1234.798 911.1976 1558.399
\end{verbatim}
}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %知识点：数据类型7：
某地区为调查新冠肺炎的感染情况，随机抽查了100人进行检测，发现有21人的检测结果呈阳性。设置信水平 $\alpha=0.10$. 使用带连续性修正的比例检验，能否拒绝感染率小于15\%的假设？

\begin{myenumerate}
\item  假设检验的 $p$ 值为0.0617，拒绝零假设。%正确
\item  假设检验的 $p$ 值为0.0617，无法拒绝零假设。
\item  假设检验的 $p$ 值为0.124，拒绝零假设。
\item  假设检验的 $p$ 值为0.124，无法拒绝零假设。
\end{myenumerate}

{\color{red}答案解析：(a)
设随机抽查一个人进行检测，结果呈阳性的概率为$p$. 这是一个未知参数。本题要检验的零假设和备选假设为 
\begin{eqnarray}
H_0:p< 0.15 \,\,\text{v.s. } \,\, H_1:p\ge 0.15.
\end{eqnarray}
注意这是单侧检验。
{\color{blue}
\begin{verbatim}
> prop.test(21,100,0.15,alt='greater')

\end{verbatim}
}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %知识点：数据类型8：
在一个单因子试验中，因子A有3个水平，每个水平各重复4次，具体数据如下，
\begin{table}[ht]
\centering
\caption{一次单因素试验的数据}\vspace{0.2cm}
\begin{tabular}{|c|cccc|} \hline 
水平 & 数据1 & 数据2 & 数据3 & 数据4   \\ \hline 
水平1 & 8 & 5 & 7 & 4    \\ \hline 
水平2 & 6 & 10 & 12 & 9    \\ \hline 
水平3 & 0 & 1 & 5 & 2    \\ \hline 
\end{tabular}
\end{table}
现进行单因素方差分析，请问因子A是否显著？设置信水平 $\alpha=0.01$. 

\begin{myenumerate}
\item  方差分析的 $p$ 值是 0.0037, 因子A是显著的。%正确
\item  方差分析的 $p$ 值是 0.0047, 因子A是显著的。
\item  方差分析的 $p$ 值是 0.0057, 因子A是显著的。
\item  方差分析的 $p$ 值是 0.0067, 因子A是显著的。

\end{myenumerate}

{\color{red}答案解析：(a). 
首先生成一个数据框，第一列为数值型的因变量数据，第二列为因子型的自变量数据。然后使用 \,{\color{blue}\verb+anova+} 函数。
{\color{blue}
\begin{verbatim}
> y<-c(8,5,7,4,6,10,12,9,0,1,5,2)
> x<-gl(3,4,12)
> mydata<-data.frame('y'=y,'x'=x)
> anova(lm(y~x,data=mydata))
\end{verbatim}
}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %知识点：数据类型9：
设来自均匀分布总体 $X\sim U(a,b)$ 的一个样本 $x_1,\cdots,x_n$ 如下。
\begin{table}[ht]
\centering
\caption{均匀分布的一个样本}\vspace{0.2cm}
%\begin{tabular}{|p{0.6cm}|c|c|c|c|c|c|c|c|c|c|} \hline 
\begin{tabular}{|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|} \hline 
$k$ & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10    \\ \hline 
$x_k$ & 9.0 & 3.1 & 7.9 & 5.2 & 4.6 & 5.8 & 9.9 & 3.2 & 2.4 & 3.3   \\ \hline 
\end{tabular}
\end{table}
下述说法中，不正确的是哪个？
\begin{myenumerate}
\item  样本均值是 5.44.
\item  无偏的样本方差是 7.092. 
\item  参数 $a$ 的矩估计是 0.828. 
\item  参数 $b$ 的矩估计是 10.520. %不正确
\end{myenumerate}

{\color{red}答案解析：(d). 
参考茆诗松的书第309页，总体均值和总体方差分别为
\begin{eqnarray}
\text{E}(X)=\frac{a+b}{2},\,\, \text{Var}(X)=\frac{(b-a)^2}{12}. 
\end{eqnarray}
矩估计的思路是令总体矩等于样本矩。参数 $b$ 的矩估计是 10.052.
{\color{blue}
\begin{verbatim}
> x<-c(9.0, 3.1, 7.9, 5.2, 4.6, 5.8, 9.9, 3.2, 2.4, 3.3)
> xbar<-mean(x)
> xbar
[1] 5.44
> varx<-var(x)
> var(x)
[1] 7.091556
> xbar-sqrt(3*varx)
[1] 0.8275531
> xbar+sqrt(3*varx)
[1] 10.05245
\end{verbatim}
}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %知识点：数据类型10：
设某种材料的抗压强度服从正态分布 $X\sim N(\mu, \sigma^2)$. 现在随机抽取10个试验件进行抗压试验，测得数据如下表。
\begin{table}[ht]
\centering
\caption{抗压强度的一个样本}\vspace{0.2cm}
%\begin{tabular}{|p{0.6cm}|c|c|c|c|c|c|c|c|c|c|} \hline 
\begin{tabular}{|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|} \hline 
$k$ & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10    \\ \hline 
$x_k$ & 482 & 493 & 457 & 471 & 510 & 446 & 435 & 418 & 394 & 369   \\ \hline 
\end{tabular}
\end{table}
求平均抗压强度 $\mu$ 的置信水平为 95\% 的置信区间。

\begin{myenumerate}
\item  $[413.9, 481.1]$. %正确
\item  $[412.9, 482.1]$. 
\item  $[411.9, 483.1]$. 
\item  $[410.9, 484.1]$. 
\end{myenumerate}

{\color{red}答案解析：(a).
总体方差未知，所以使用 $t$ 统计量。根据 
%\begin{eqnarray}
$T=\frac{\bar{X}-\mu}{S/\sqrt{n}}\sim t(n-1)$,
%\end{eqnarray}
可得置信水平为 $1-\alpha$ 的置信区间为
%\begin{eqnarray}
$[ \bar{x} - t_{\alpha/2}(n-1)s/\sqrt{n}, \bar{x} + t_{\alpha/2}(n-1)s/\sqrt{n} ]$. 
%\end{eqnarray}
代入数据，直接计算。注：使用 \,{\color{blue}\verb+t.test+} 函数，结果不一样。为什么？

{\color{blue}
\begin{verbatim}
> x<-c(482,493,457,471,510,446,435,418,394,369)
> mean(x) - qt(0.975,9)*sd(x)/sqrt(9)
[1] 413.9068
> mean(x) + qt(0.975,9)*sd(x)/sqrt(9)
[1] 481.0932
> t.test(x)
\end{verbatim}
}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{enumerate}

\end{document}





